<template>
  <a-drawer v-model:visible="visible" title="压测用例详情" :width="width >= 580 ? 580 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="项目id">{{ dataDetail?.projectId }}</a-descriptions-item>
      <a-descriptions-item label="所属接口模块ID">{{ dataDetail?.moduleId }}</a-descriptions-item>
      <a-descriptions-item label="">{{ dataDetail?.environmentId }}</a-descriptions-item>
      <a-descriptions-item label="接口名称">{{ dataDetail?.name }}</a-descriptions-item>
      <a-descriptions-item label="接口描述">{{ dataDetail?.description }}</a-descriptions-item>
      <a-descriptions-item label="响应断言">{{ dataDetail?.assertion }}</a-descriptions-item>
      <a-descriptions-item label="可变参数">{{ dataDetail?.relation }}</a-descriptions-item>
      <a-descriptions-item label="压测类型 [simple jmx]">{{ dataDetail?.stressSourceType }}</a-descriptions-item>
      <a-descriptions-item label="压测参数">{{ dataDetail?.threadGroupConfig }}</a-descriptions-item>
      <a-descriptions-item label="jmx文件地址">{{ dataDetail?.jmxUrl }}</a-descriptions-item>
      <a-descriptions-item label="接口路径">{{ dataDetail?.path }}</a-descriptions-item>
      <a-descriptions-item label="请求方法 [GET POST PUT PATCH DELETE HEAD OPTIONS]">{{ dataDetail?.method }}</a-descriptions-item>
      <a-descriptions-item label="查询参数">{{ dataDetail?.query }}</a-descriptions-item>
      <a-descriptions-item label="请求头">{{ dataDetail?.header }}</a-descriptions-item>
      <a-descriptions-item label="请求体">{{ dataDetail?.body }}</a-descriptions-item>
      <a-descriptions-item label="请求体格式 [raw form-data json]">{{ dataDetail?.bodyType }}</a-descriptions-item>
      <a-descriptions-item label="乐观锁">{{ dataDetail?.version }}</a-descriptions-item>
      <a-descriptions-item label="业务状态">{{ dataDetail?.status }}</a-descriptions-item>
      <a-descriptions-item label="逻辑删除 1: 已删除， 0: 未删除">{{ dataDetail?.isDeleted }}</a-descriptions-item>
      <a-descriptions-item label="创建者">{{ dataDetail?.createdBy }}</a-descriptions-item>
      <a-descriptions-item label="更新者">{{ dataDetail?.updatedBy }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createdAt }}</a-descriptions-item>
      <a-descriptions-item label="更新时间">{{ dataDetail?.updatedAt }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script lang="ts" setup>
import { useWindowSize } from '@vueuse/core'
import { type StressCaseDetailResp, getStressCase } from '@/apis'

const { width } = useWindowSize()

const visible = ref(false)
const dataId = ref('')
const dataDetail = ref<StressCaseDetailResp>()
// 查询详情
const getDataDetail = async () => {
  const res = await getStressCase(dataId.value)
  dataDetail.value = res.data
}

// 打开详情
const onDetail = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onDetail })
</script>

<style lang="scss" scoped></style>
